package com.manlitech.cloudboot.common.utils;


import org.joda.time.DateTime;

import java.util.List;

public class ResultUtil {

    public static Result success(Object object) {
        Result result = new Result();
        result.setCode(0);
        result.setMsg("成功");
        result.setData(object);
        result.setSystemTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
        return result;
    }

    public static Result success(Integer code , String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setSystemTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
        return result;
    }

    public static Result success(List list,Long total) {
        Result result = new Result();
        result.setCode(0);
        result.setMsg("成功");
        result.setData(list);
        result.setRows(total);
        result.setSystemTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
        return result;
    }

    public static Result success() {
        return success(null);
    }

    public static Result error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setSystemTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
        return result;
    }
    
    public static Result error(Integer code, String msg ,Object object) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(object);
        result.setSystemTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
        return result;
    }
}
